﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="../../common/jsp/taglibs.jsp"%>
<!-- 
    Copyright (C)  2011  chen wei hua.
    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 2.0
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU Free Documentation License".
 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>仓库管理-初始化库存</TITLE>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<%@ include file="../../common/jsp/config.jsp"%>
<%@ include file="../../common/jsp/validate.jsp"%>
<script type="text/javascript" src="common/js/calendar/WdatePicker.js" ></script>
<script type="text/javascript">
function openSelectDialog() {
 	alertDialog(700, 500, "showSelectMaterialsDialog.action", 
 	function (result) {
 		var materials = result.materials;
 		if (materials) {
 			$("#materialsId").val(materials.id);
 			$("#skuDetailId").val(result.skuId);
     		var str = '<td>' + materials.rootCategory.name + '</td>';
     		str += '<td>' + materials.category.name + '</td>';
     		str += '<td>' + materials.name + '</td>';
     		str += '<td>' + materials.type + '</td>';
     		str += '<td>' + materials.units + '</td>';
     		$("#materialsInfoTable").find("tr:last").empty().append(str);
 		}
 	});
}
function querySubmit() {
	$("#queryInitMaterialsBatchDetail").attr("action", "queryInitMaterialsBatchDetail.action");
	$("#queryInitMaterialsBatchDetail").submit();
}
function saveSubmit() {
	$("#queryInitMaterialsBatchDetail").attr("action", "saveInitMaterialsBatchDetail.action");
	$("#queryInitMaterialsBatchDetail").submit();
}
$(document).ready(function() {
	$("#queryInitMaterialsBatchDetail").validate();
});
</script>
</HEAD>
<BODY>
    <div class="subnav" align="left">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td width="100%" align="left" height="31">&nbsp;<img src="common/images/title-pk.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt1">仓库管理</span>
			&nbsp;<img src="common/images/leftico2.gif" border="0"  align="absmiddle"/>&nbsp;<span class="subnavtxt2">初始化库存</span></td>
		  </tr>
		</table>
    </div>
   <s:actionerror cssStyle="color:red"/>
   <s:actionmessage />
   <div class="divborder">
      <s:form action="initMaterialsMonthBatchDetail" method="post" enctype="multipart/form-data">
          导入Excel文件：<s:file name="excelFile"></s:file>
      	<br/>
    	<s:submit value="导入"></s:submit>
      </s:form>
    </div>
   <s:form action="queryInitMaterialsBatchDetail">
   <div class="divborder">

        <table width="100%" border="0" cellspacing="1" cellpadding="3">
          <tr>
            <td width="10%" align="right">月份</td>
            <td width="25%">
				<s:textfield name="queryDate" onclick="WdatePicker({dateFmt:'yyyy-MM'})" readonly="true" size="10" />
			</td>
            <td width="10%" align="right">在库品</td>
            <td width="25%">
			    <input type="button" value="请选择" onclick="openSelectDialog()" />
			    <s:hidden id="materialsId" name="materialsId" />
			    <s:hidden id="skuDetailId" name="skuDetailId" />
			</td>
            <td align="right"><input name="button" type="button" class="input1" value="查 询" onclick="querySubmit()"/></td>
          </tr>
          <tr>
            <td colspan="5">
			  <div class="ksglxx2">
			    <table id="materialsInfoTable" width="500px" cellpadding="0" cellspacing="1" border="0" class="ksglxx2a">
			        <tr class="ksglxx2bg">
			          <th width="50px" >大分类</th>
			          <th width="60px" >中分类</th>
			          <th width="95px" >名称</th>
			          <th width="180px" >型号</th>
					  <th width="50px">单位</th>
					</tr>
			        <tr class="odd">
			          <td><s:property value="materials.rootCategory.name" /></td>
			          <td><s:property value="materials.category.name" /></td>
			          <td><s:property value="materials.name" /></td>
			          <td><s:property value="materials.type" /></td>
			          <td><s:property value="materials.units" /></td>
					</tr>
            	</table>
			  </div>
            </td>
          </tr>
        </table>
    </div>
  <div class="ksglxx2">
      <table width="900px" cellpadding="0" cellspacing="1" border="0" class="ksglxx2a">
        <tr class="ksglxx2bg">
          <th width="50px" >大分类</th>
          <th width="60px" >中分类</th>
          <th width="95px" >名称</th>
          <th width="180px" >型号</th>
          <th width="180px" >其他</th>
		  <th width="50px">单位</th>
		  <th width="120px">批号<span class="red-text1">*</span></th>
		  <th width="95px" >价格<span class="red-text1">*</span></th>
		  <th width="95px" >合格数<span class="red-text1">*</span></th>
		  <th width="95px" >不合格数<span class="red-text1">*</span></th>
		  <th></th>
		</tr>
		<s:iterator value="materialsBatchMonthDetails" id="detail" status="st">
	      <s:if test="#st.Odd">
	        <tr class="odd">
	      </s:if >
	      <s:else>
	        <tr class="even">
	      </s:else>
              <td><s:property value="#detail.skuDetail.materials.rootCategory.name" /></td>
              <td><s:property value="#detail.skuDetail.materials.category.name" /></td>
              <td><s:property value="#detail.skuDetail.materials.name" /></td>
              <td><s:property value="#detail.skuDetail.materials.type" /></td>
              <td><s:property value="#detail.skuDetail.customFieldCombox" /></td>
              <td><s:property value="#detail.skuDetail.materials.units" /></td>
              <td><s:textfield id="batchNos-%{#st.index}" name="batchNos" value="%{#detail.batchNo}" size="10" cssClass="{required:true,maxlength:10}"/></td>
              <td><s:textfield name="prices" value="%{#detail.price}" size="10" cssClass="{required:true,maxlength:10,number:true}"/></td>
              <td><s:textfield name="numbers" value="%{#detail.number}" size="10" cssClass="{required:true,maxlength:10,number:true}"/></td>
              <td><s:textfield name="defectiveNumbers" value="%{#detail.defectiveNumber}" size="10" cssClass="{required:true,maxlength:10,number:true}"/></td>
              <td><s:hidden name="detailIds" value="%{#detail.id}" />
              	  <s:hidden name="skuDetailIds" value="%{#detail.skuDetail.id}" />
              </td>
	        </tr>
	    </s:iterator>
       </table>
   </div>
     </s:form>
	<div class="main_1">
		<table width="98%" border="0" cellpadding="5" cellspacing="0" class="gr-text1">
		   <tr>
			 <td>
			 <input name="button" type="button" class="input1" value="保  存" onclick="saveSubmit()"/>
			 </td>
		   </tr>
	   </table>
	</div>
</BODY></HTML>
